<{include file="public/header.html"}>
	<!--问答详情 内容-->
	<div class="wd-answer mt2 mb10">
		<div class="plr15 ptb10 border-bottom-sm bj-grey">
			<{if $item['tags']}>
			<div class="problem-label">
				<{foreach from=$item['tags'] item=val}>
				<span><{$val['tname']}></span>
				<{/foreach}>
			</div>
			<{/if}>
			<p><{$item['title']}></p>
		</div>
		<div class="answer bj-grey">
			<div class="plr15 wd-descript">
				<div class="user-head pt10 f-cb">
					<img src="<{$item['head_img']}>" id="<{$item['questioner_id']}>" class="head fl"/>
					<span class="name fl ml5"><{$item['nickname']}></span>
					<img src="/static/mobile/img/vip/vip1.png" class="badge fl ml5"/>
					<p class="time fr"><{$item['create_time']}></p>
				</div>
				<{if $item['content']}>
				<div class="text-all">
					<{$item['content']}>
				</div>
				<{/if}>
			</div>
			<button class="w100 hide _show_hide" onclick="showHide(this)">
				<i class="iconfont col-red a">展开&#xe633;</i>
				<i class="iconfont col-red b disnone">收起&#xe6f7;</i>
			</button>
		</div>
		<ul>
			<{foreach from=$list item=val}>
			<li>
				<div class="mlr15 ptb10 answer border-bottom-lg disblock">
					<div class="user-head f-cb">
						<img src="<{$val['head_img']}>" id="<{$val['user_id']}>" class="head fl"/>
						<span class="name fl ml5"><{$val['nickname']}></span>
						<img src="/static/mobile/img/vip/vip1.png" class="badge fl ml5"/>
						<{if $val['status']==1}>
						<button class="adopt fr iconfont active">&#xe697; <i>最佳答案</i></button>
						<{/if}>
						<{if $val['status']==2}>
						<button class="adopt fr iconfont">&#xe697; <i>采纳为答案</i></button>
						<{/if}>
					</div>
					<a href="answer_detail.html" id="<{$val['id']}>" class="disblock">
						<p class="text textnum60">
							<{$val['content']}>
						</p>
						<p class="all col-red">查看更多>></p>
						<ul class="proportion-img ptb5">
							<{if $val['picture']}>
							<{foreach from=$val['picture'] item=img}>
								<{$img}>
							<{/foreach}>
							<{/if}>
						</ul>
					</a>
					<div class="num f-cb">
						<a href="javascript:;" onclick="funWdLike(this,<{$val['id']}>)"><font class="iconfont <{if $val['is_like']}>col-redf941<{else}>col-grey999<{/if}>">&#xe615;<i class="_like"><{$val['likes']}></i></font></a>
						<font class="iconfont col-grey999 fr">&#xe675;<i><{$val['commentnum']}></i></font>
					</div>
				</div>
			</li>
			<{/foreach}>
		</ul>
	</div>
	
	<script type="text/javascript">
		//点赞+1
		function funWdLike(e,n){
			$(e).children('.iconfont').addClass('col-redf941');
			var likeNum = $(e).find('._like').text();
			likeNum = parseInt(likeNum) + 1;
			$(e).find('._like').text(likeNum);
//			var like = document.getElementById("_like_num"),
//				zan = like.firstChild,
//				zan_num = like.lastChild;
//			zan.setAttribute('class','col-redf941 iconfont');
//			zan_num.value = parseInt(zan_num.value) + 1;
		}
		//展开收起
	    function showHide(e){
	    	var _this = $(e);
	    	var toggle = _this.hasClass('show');
			if ( toggle ){
				_this.removeClass('show').siblings(".wd-descript").css('height','0');
			}else{
				_this.addClass('show').siblings(".wd-descript").animate({height:'100%'},1000);
			}
	    }
		//采纳答案
		function getElementsByClassName(n) { 
			var elems = document.getElementsByTagName("button"),
				len = elems.length;
	        var arr = [];
	        for(var i = 0;i<len;i++){
	            if(elems[i].className == "adopt"){
	                arr.push(elems[i]);
		            console.log(arr);
	            }
	        }
		} 
		getElementsByClassName();
		
		var adpot = document.querySelector('.adpot');
		$('.user-head button.adopt').click(function(){
			$(this).hasClass('active') ? $(this).removeClass('active') : $(this).addClass('active');
			$(this).find('i').text('采纳为最佳答案') ? $(this).find('i').text('采纳为答案') : $(this).find('i').text('最佳答案');
		});
	    
	</script>
<{include file="public/footer.html"}>	